home *** CD-ROM | disk | FTP | other *** search
/ Utilities Professional 1-1500 / Utilities Professional 1-1500 (1994)(WPD)[!].iso / 12511500 / var1453.dms / var1453.adf / Lists / Lists.doc < prev    next >
Text File  |  1992-05-02  |  21KB  |  780 lines

  1. 3    LISTS
  2.  
  3. 3.1  INTRODUCTION
  4.  
  5. Amiga has a multi tasking operating system which means that
  6. several tasks (programs) can be running simultaneously. This
  7. unique feature is controlled by "Exec" - "the multi tasking
  8. executive". To make it possible for Exec to control several
  9. tasks it uses a complex system of "lists" and "messages".
  10.  
  11.  
  12.  
  13. 3.2  THE LIST
  14.  
  15. A list consists of a "header" and a linked list of "nodes".
  16. The header consists of two pointers to the first and last nodes
  17. in the linked list as well as a field that tells Exec what
  18. type of nodes the list will contain.
  19.  
  20.  
  21.  
  22. 3.2.1  THE LIST STRUCTURE
  23.  
  24. The List structure look like this: (Defined in the header
  25. file "exec/lists.h")
  26.  
  27. struct List
  28. {
  29.   struct Node *lh_Head;
  30.   struct Node *lh_Tail;
  31.   struct Node *lh_TailPred;
  32.   UBYTE lh_Type;
  33.   UBYTE lh_pad;
  34. };
  35.  
  36. lh_Head:     Pointer to the first node in the linked list.
  37.  
  38. lh_Tail:     Is always zero.
  39.  
  40. lh_TailPred: Pointer to the last node in the linked list.
  41.  
  42. lh_Type:     Tells Exec what types of nodes there are in the
  43.              list. See header file "exec/nodes.h" for a complete
  44.              list of the node types. Here are some commonly used
  45.              types:
  46.             
  47.              NT_UNKNOWN   Type unknown (How could you guess that?)
  48.              NT_TASK      A task node.
  49.              NT_INTERRUPT An interrupt (also software interrupt)
  50.              NT_SOFTINT   Only used by Exec itself.
  51.              etc...
  52.  
  53. lh_pad:      Not used. (Aligns the structure to the infamous even
  54.              bytes boundary.)
  55.  
  56.  
  57.  
  58. 3.2.2  INITIALIZE THE LIST STRUCTURE
  59.  
  60. Before you may use the list structure you have to initialize it.
  61. Simply follow these steps:
  62.  
  63. 1. Set the lh_Head pointer to the address of lh_Tail.
  64.  
  65. 2. Set the lh_Tail pointer to NULL. (Should always be NULL.)
  66.  
  67. 3. Set the lh_TailPred pointer to the address of lh_Head.
  68.  
  69. 4. Set the lh_Type field to the desired node type. (Note, all
  70.    nodes in the list should be of the same type as the lh_Type.)
  71.  
  72.  
  73. Here is an example:
  74.  
  75. struct List plans;
  76. plans.lh_Head = &plans.lh_Tail;
  77. plans.lh_Tail = NULL;
  78. plans.lh_TailPred = &plans.lh_Head;
  79. plans.lh_Type = NT_UNKNOWN;
  80.  
  81.  
  82. This can be replaced by calling the NewList() function, with a
  83. pointer to the list structure as the only argument. 
  84.  
  85. Synopsis: NewList( list );
  86.  
  87. list:     (struct List *) Pointer to the list that should be
  88.           initialized.
  89.  
  90.  
  91. Example: NewList( &plans );
  92.  
  93.  
  94.  
  95. 3.2.3  MINI LISTS
  96.  
  97. There exist a special type of mini lists that are exactly the
  98. same as the normal lists except that no type checking is used
  99. and it only contains mini nodes. (Mini nodes are discussed
  100. further down. They are like normal nodes but without any
  101. priority nor type definitions.) The MinList structure look
  102. like this: (Also defined in the header file "exec/lists.h")
  103.  
  104. struct MinList
  105. {
  106.   struct MinNode *mlh_Head;
  107.   struct MinNode *mlh_Tail;
  108.   struct MinNode *mlh_TailPred;
  109. };
  110.  
  111. mlh_Head:     Pointer to the first mini node in the linked list.
  112.  
  113. mlh_Tail:     Is always zero.
  114.  
  115. mlh_TailPred: Pointer to the last mini node in the linked list.
  116.  
  117.  
  118. These mini lists are used when you only want to use double
  119. linked lists but do not bother about types, priority or names.
  120. Note that these lists can NOT be used by some of the lists
  121. function described further down! (It would be ridiculous, and
  122. very dangerous, to search a mini list for nodes with special
  123. names, for example.)
  124.  
  125.  
  126.  
  127. 3.3  NODES
  128.  
  129. A list is a double linked lists of nodes. (A double linked lists
  130. means that you can both go forward as well as backwards in the
  131. list.) The node consists of two parts:
  132.  
  133.   1. A node structure with which the nodes are linked together
  134.      with. It also contains information such as node type and
  135.      priority (more about this later). Each node structure has
  136.      also a name which is used to identify the nodes. (Very
  137.      useful during debugging.)
  138.  
  139.   2. The data itself. This can be anything you like.
  140.  
  141.  
  142.  
  143. 3.3.1  THE NODE STRUCTURE
  144.  
  145. The node structure look like this: (Defined in the header file
  146. "exec/nodes.h")
  147.  
  148. struct Node
  149. {
  150.   struct Node *ln_Succ;
  151.   struct Node *ln_Pred;
  152.   UBYTE ln_Type;
  153.   BYTE ln_Pri;
  154.   char *ln_Name;
  155. };
  156.  
  157. ln_Succ: Pointer to the next node. (Successor)
  158.  
  159. ln_Pred: Pointer to the previous node in the list. (Predecessor)
  160.  
  161. ln_Type: Type of node. See header file "exec/nodes.h" for a
  162.          complete list of the node types. (See above for some
  163.          examples.)
  164.  
  165. ln_Pri:  This node's "priority" - a value between -128 and +127.
  166.          The higher value the higher priority. The priority can
  167.          for example be used when the list is sorted. If you
  168.          do not use the priority field, set it to 0.
  169.  
  170. ln_Name: Pointer to a NULL terminating string which contains
  171.          the name of this node. (Useful for debugging.) 
  172.  
  173.  
  174.  
  175. 3.3.2  INITIALIZE THE NODE STRUCTURE
  176.  
  177. Before you may put the node into the list you have to initialize
  178. it. You do it by setting the ln_Type, ln_Pri and ln_Name field
  179. as desired. The ln_Succ and ln_Pred pointers will automatically
  180. be initialized when the node is placed into the list.
  181.  
  182. Here is an example:
  183.  
  184. struct Node my_first_node;
  185. my_first_node.ln_Type = NT_UNKNOWN; /* A strange node. */
  186. my_first_node.ln_Pri = 25;          /* A rather important node. */
  187. my_first_node.ln_Name = "Napoleon"  /* This node's name. */ 
  188.  
  189.  
  190.  
  191. 3.3.3  CREATE A COMPLETE NODE
  192.  
  193. A complete node consists, as said above, of two parts. First we
  194. have the node structure itself, then we have the data. Here is
  195. an example how to create your own complete node:
  196.  
  197.  
  198. /* Declare the COMPLETE node structure: */
  199. struct Person author=
  200. {
  201.   /* Succ  Pred    Type     Pri    Name                */
  202.   { NULL, NULL, NT_UNKNOWN, 127, "Anders" }, /* Part 1 */
  203.   CPTR data1;                                /* Part 2 */
  204.   CPTR data2;
  205.   CPTR data3;
  206. };
  207.  
  208.  
  209.  
  210. 3.3.4  MINI NODES
  211.  
  212. As there exist mini lists there also exist mini nodes. They
  213. are like normal nodes, but without type definition, priority
  214. and name.  The MinNode structure look like this: (Also defined
  215. in the header file "exec/nodes.h")
  216.  
  217. struct MinNode
  218. {
  219.   struct MinNode *mln_Succ;
  220.   struct MinNode *mln_Pred;
  221. };
  222.  
  223. mln_Succ: Pointer to the next mini node. (Successor)
  224.  
  225. mln_Pred: Pointer to the previous mini node in the list.
  226.           (Predecessor)
  227.  
  228.  
  229.  
  230. 3.4  INSERT AND REMOVE LISTS
  231.  
  232. Once you have initialized a complete node you can insert it into
  233. a linked list. You would then probably use the Insert() function,
  234. but if you want to insert it first or last into a list you should
  235. rather use the functions AddHead() or AddTail() function. To
  236. remove a node use the function Remove(). To remove the first or
  237. last node in the list you should use the RemHead() or RemTail()
  238. functions since they are much faster. There exist even a
  239. function to insert nodes and positions them corresponding to
  240. their priorities.
  241.  
  242.  
  243.  
  244. 3.4.1  INSERT NODES INTO A LIST
  245.  
  246. To insert a node into a list use the Insert() function:
  247.  
  248. Synopsis: Insert( list, node, pred );
  249.  
  250. list:     (struct List *) Pointer to the list you wish to
  251.           insert the node in.
  252.  
  253. node:     (struct Node *) Pointer to the node you want to insert.
  254.  
  255. pred:     (struct Node *) Pointer to a node which the new node
  256.           should be placed after. (If this field is NULL or
  257.           points to the list header the node will be inserted
  258.           first in the list. If this field points to the list's
  259.           lh_Tail field the node will be inserted last in the
  260.           list. However, if you which to insert a node first or
  261.           last in a list you should use the faster functions
  262.           AddHead() or AddTail().)
  263.  
  264. Here is an example how to insert the node "author" just after
  265. the node "housekeeper" in the "plans" list:
  266.  
  267. Insert( &plans, &author, &housekeeper );
  268.  
  269.  
  270.  
  271. 3.4.1.1  INSERT NODES AT THE HEAD OF A LIST
  272.  
  273. If you want to insert a node a the head of a list you are
  274. recommended to use the fast AddHead() function.
  275.  
  276. Synopsis: AddHead( list, node )
  277.  
  278. list:     (struct List *) Pointer to the list you wish to
  279.           insert the node in.
  280.  
  281. node:     (struct Node *) Pointer to the node you want to insert.
  282.  
  283.  
  284. Here is an example how to insert the node "author" at the head
  285. of the list "plans":
  286.  
  287. AddHead( &plans, &author );
  288.  
  289.  
  290.  
  291. 3.4.1.2  INSERT NODES AT THE TAIL OF A LIST
  292.  
  293. If you want to insert a node a the tail of a list you are
  294. recommended to use the fast AddTail() function.
  295.  
  296. Synopsis: AddTail( list, node )
  297.  
  298. list:     (struct List *) Pointer to the list you wish to
  299.           insert the node in.
  300.  
  301. node:     (struct Node *) Pointer to the node you want to insert.
  302.  
  303.  
  304. Here is an example how to insert the node "author" at the tail
  305. of the list "plans":
  306.  
  307. AddTail( &plans, &author );
  308.  
  309.  
  310.  
  311. 3.4.2  REMOVE NODES FROM A LIST
  312.  
  313. To remove a node from a list use the Remove() function:
  314.  
  315. Synopsis: Remove( node );
  316.  
  317. node:     (struct Node *) Pointer to the node you want to insert.
  318.  
  319. Here is an example how to remove the node "author":
  320.  
  321. Remove( &author );
  322.  
  323.  
  324.  
  325. 3.4.2.1  REMOVE NODES AT THE HEAD OF A LIST
  326.  
  327. If you want to remove a node a the head of a list you are
  328. recommended to use the fast RemHead() function. This function
  329. will also return a pointer to the removed node, or NULL if
  330. there were no more nodes to remove.
  331.  
  332. Synopsis: node = RemHead( list )
  333.  
  334. list:     (struct List *) Pointer to the list you wish to
  335.           remove the head node from.
  336.  
  337. node:     (struct Node *) Pointer to the node you have
  338.           removed.
  339.  
  340.  
  341. Here is an example how to remove the node at the head of the
  342. list "plans": (node_ptr is a pointer to node structures.)
  343.  
  344. node_ptr = RemHead( &plans );
  345.  
  346.  
  347.  
  348. 3.4.2.2  REMOVE NODES AT THE TAIL OF A LIST
  349.  
  350. If you want to remove a node a the tail of a list you are
  351. recommended to use the fast RemTail() function. This function
  352. will also return a pointer to the removed node, or NULL if
  353. there were no more nodes to remove.
  354.  
  355. Synopsis: node = RemTail( list )
  356.  
  357. list:     (struct List *) Pointer to the list you wish to
  358.           remove the tail node from.
  359.  
  360. node:     (struct Node *) Pointer to the node you have
  361.           removed.
  362.  
  363.  
  364. Here is an example how to remove the node at the tail of the
  365. list "plans": (node_ptr is a pointer to node structures.)
  366.  
  367. node_ptr = RemHead( &plans );
  368.  
  369.  
  370.  
  371. 3.4.3  FIFO AND LIFO
  372.  
  373. The functions above can be combined to generate "First In First
  374. Out" (FIFO) or "Last In First Out" (LIFO).
  375.  
  376. FIFO Use the functions AddTail() and RemHead() to generate a
  377.      first in first out list. The first node you inserted into
  378.      the list will also be the first node to be removed. (This
  379.      is like a normal queue.)
  380.  
  381. LIFO Use the functions AddHead() and RemHead() to generate a
  382.      last in first out list. The last node you inserted into
  383.      the list will also be the first node to be removed. (This
  384.      is like a putting nodes onto a "stack".)
  385.  
  386.  
  387.  
  388. 3.4.4  INSERT NODES CONSIDERING THEIR PRIORITIES
  389.  
  390. If you want to insert nodes and use the nodes' priorities to
  391. decide where in the list they should be placed you can use
  392. the Enqueue() function. The node with the highest priority will
  393. be placed at the head of the list, and the lower priority the
  394. further back into the list the nodes will be placed. If you
  395. insert a node with the same priority as an already existing
  396. one, your node will be placed after that one. (FIFO)
  397.  
  398. To pick out the nodes with the highest priorities first you
  399. should then use the RemHead() function. To pick out the nodes
  400. with the lowest priorities first you should use the RemTail()
  401. function.
  402.  
  403. Synopsis: Enqueue( list, node );
  404.  
  405. list:     (struct List *) Pointer to the list you wish to
  406.           insert the node in.
  407.  
  408. node:     (struct Node *) Pointer to the node you want to
  409.           insert.
  410.  
  411.  
  412. NOTE! This function can of course not be used to handle mini
  413. lists. (Mini nodes do not have any priority field.)
  414.  
  415.  
  416.  
  417. 3.5  WORK WITH THE LISTS
  418.  
  419. Here are some common ways to work with lists and nodes. 
  420.  
  421.  
  422.  
  423. 3.5.1  IS THE LIST EMPTY?
  424.  
  425. If you want to determine if a list is empty you simply check
  426. if the ln_Succ field of the node lh_Head points to is NULL.
  427. (This may seem a bit strange, but remember that when you
  428. initialize the list structure you set the lh_Head field to
  429. the address of lh_Tail.)
  430.  
  431.   if( my_list.lh_Head->ln_Succ == NULL )
  432.     printf( "This list is empty!\n" );
  433.  
  434.  
  435.  
  436. 3.5.2  SCAN THROUGH A LIST
  437.  
  438. The lists are, as mentioned above, double linked. You can
  439. therefore scan through a list either from the head to the tail
  440. or from the tail to the head.
  441.  
  442. Example on how to scan through a list from the head to the tail:
  443.  
  444.   struct Node *ptr;
  445.   
  446.   /* Set the node pointer so it points to the first node: */
  447.   ptr = (struct Node *) my_list.lh_Head;
  448.  
  449.   /* Stay in the loop as long as there is a node after this one: */
  450.   while( ptr->ln_Succ )
  451.   {
  452.     printf( "Node %s\n", ptr->ln_Name );
  453.     ptr = ptr->ln_Succ;
  454.   }
  455.  
  456.  
  457. Example on how to scan through a list from the tail to the head:
  458.  
  459.   struct Node *ptr;
  460.  
  461.   /* Set the node pointer so it points to the last node: */
  462.   ptr = (struct Node *) my_list.lh_TailPred;
  463.  
  464.   /* Stay in the loop as long as there is a node before this one: */
  465.   while( ptr->ln_Pred )
  466.   {
  467.     printf( "Node %s\n", ptr->ln_Name );
  468.     ptr = ptr->ln_Pred;
  469.   }
  470.  
  471.  
  472.  
  473. 3.5.3  SEARCH FOR A NODE WITH A SPECIAL NAME
  474.  
  475. It is sometimes necessary to find nodes with special names. The
  476. FindName() function is here very useful. You only need to
  477. specify what name you look for and which list should be examined.
  478. The function will either return a pointer to the first node in
  479. the list with that name, or NULL if no node with the specified
  480. name was found. If you find a node you only have to call the
  481. function again (this time with the node pointer instead of the
  482. list pointer) to find the next correct node.
  483.  
  484. Synopsis: node = FindName( list, name );
  485.  
  486. node:     (struct Node *) If FindName() finds a node with the
  487.           name "name" it returns a pointer to it. If no node
  488.           was found it returns NULL.
  489.  
  490. list:     (struct List *) Pointer to the list you want to
  491.           examine. If you have already found a node and want to
  492.           search for the next you should give it a pointer to
  493.           the last node you found.
  494.  
  495. name:     (char *) Pointer to a NULL terminated string that
  496.           contains the name of the node(s) you look for.
  497.  
  498.  
  499.   /* Find the first node with the name "Internal": */
  500.   node_ptr = (struct Node *) FindName( &my_list, "Internal" );
  501.   
  502.   /* As long as we find nodes with the name "Internal" we */
  503.   /* stay in the loop:                                    */
  504.   while( node_ptr )
  505.   {
  506.     /* Do what ever you want with the node: */
  507.     printf( "Node %lX is internal.\n", node_ptr );
  508.  
  509.     /* Try to find yet another node: */
  510.     node_ptr = (struct Node *) FindName( node_ptr, "Internal" );
  511.   }
  512.  
  513.  
  514. NOTE! This function can of course not be used to handle mini
  515. lists. (Mini nodes do not have any name field.)
  516.  
  517.  
  518.  
  519. 3.6  A COMPLETE EXAMPLE
  520.  
  521. Here is a not very exciting but complete list example:
  522.  
  523. #include <exec/types.h>
  524. #include <exec/lists.h> /* This file will automatically */
  525.                         /* include the file "nodes.h".  */
  526.  
  527.  
  528. /* Declare a complete node structure: */
  529. struct ToDo
  530. {
  531.   struct Node node; /* Every node must have this. */
  532.   STRPTR Wish;      /* Our own data.              */
  533. };
  534.  
  535.  
  536. /* Declare a list structure: */
  537. struct List my_list;
  538.  
  539.  
  540. /* Node 1: */
  541. struct ToDo eat=
  542. {
  543.   { NULL, NULL, NT_UNKNOWN, 0, "Food" },
  544.   "eat breakfast"
  545. };
  546.  
  547. /* Node 2: */
  548. struct ToDo sleep=
  549. {
  550.   { NULL, NULL, NT_UNKNOWN, 0, "Sleep" },
  551.   "rest"
  552. };
  553.  
  554. /* Node 3: */
  555. struct ToDo drink=
  556. {
  557.   { NULL, NULL, NT_UNKNOWN, 0, "Food" },
  558.   "drink some nice wine"
  559. };
  560.  
  561.  
  562. main()
  563. {
  564.   /* Declare a node pointer: */
  565.   struct Node *ptr;
  566.  
  567.   /* Declare a pointer to ToDo structures: */
  568.   struct ToDo *todo_ptr;
  569.   
  570.   
  571.   /* Initialize our list structure: */
  572.   NewList( &my_list );
  573.  
  574.  
  575.   /* Add three nodes: */
  576.   AddTail( &my_list, &eat );
  577.   AddTail( &my_list, &sleep );
  578.   AddTail( &my_list, &drink );
  579.  
  580.  
  581.   /* Check if the list is empty or not: */
  582.   if( my_list.lh_Head->ln_Succ == NULL )
  583.     printf( "This list is empty!\n" );
  584.   else
  585.     printf( "This list is not empty!\n" );
  586.  
  587.  
  588.   /* Scan through the list: (Head to Tail) */
  589.   ptr = (struct Node *) my_list.lh_Head;
  590.   while( ptr->ln_Succ )
  591.   {
  592.     printf( "Node %lX\n", ptr, ptr );
  593.     ptr = ptr->ln_Succ;
  594.   }
  595.  
  596.  
  597.   /* Find all nodes with the name "Food": */
  598.   ptr = (struct Node *) FindName( &my_list, "Food" );
  599.   while( ptr )
  600.   {
  601.     todo_ptr = (struct ToDo *) ptr;
  602.     printf( "I want to %s.\n", todo_ptr->Wish );
  603.     ptr = (struct Node *) FindName( ptr, "Food" );
  604.   }
  605.  
  606.  
  607.   /* Remove all nodes: */
  608.   RemHead( &my_list, &eat );
  609.   RemHead( &my_list, &sleep );
  610.   RemHead( &my_list, &drink );
  611. }
  612.  
  613.  
  614.  
  615. 3.7  FUNCTIONS
  616.  
  617. NewList()
  618.  
  619.   This function initializes a list structure.
  620.  
  621.   Synopsis: NewList( list );
  622.  
  623.   list:     (struct List *) Pointer to the list that should be
  624.             initialized.
  625.  
  626.  
  627. Insert()
  628.  
  629.   This function is used to insert nodes into a list. If the
  630.   node should be placed first or last in the list you should
  631.   use the faster functions AddHead() or AddTail().
  632.  
  633.   Synopsis: Insert( list, node, pred );
  634.  
  635.   list:     (struct List *) Pointer to the list you wish to
  636.             insert the node in.
  637.  
  638.   node:     (struct Node *) Pointer to the node you want to
  639.             insert.
  640.  
  641.   pred:     (struct Node *) Pointer to a node which the new
  642.             node should be placed after. (If this field is NULL
  643.             or points to the list header the node will be
  644.             inserted first in the list. If this field points to
  645.             the list's lh_Tail field the node will be inserted
  646.             last in the list. However, if you which to insert
  647.             a node first or last in a list you should use the
  648.             faster functions AddHead() or AddTail().)
  649.  
  650.  
  651. Remove()
  652.  
  653.   This function is used to remove nodes from a list. If the
  654.   node should be removed at the tail of the list you should use
  655.   the faster functions RemHead() or RemTail().
  656.  
  657.   Synopsis: Remove( node );
  658.  
  659.   node:     (struct Node *) Pointer to the node you want to
  660.             insert.
  661.  
  662.   Here is an example how to remove the node "author":
  663.  
  664.  
  665. AddHead()
  666.  
  667.   This function will add a note at the head of a list.
  668.  
  669.   Synopsis: AddHead( list, node )
  670.  
  671.   list:     (struct List *) Pointer to the list you wish to
  672.             insert the node in.
  673.  
  674.   node:     (struct Node *) Pointer to the node you want to
  675.             insert.
  676.  
  677.  
  678. AddTail()
  679.  
  680.   This function will add a note at the tail of a list.
  681.  
  682.   Synopsis: AddTail( list, node )
  683.  
  684.   list:     (struct List *) Pointer to the list you wish to
  685.             insert the node in.
  686.  
  687.   node:     (struct Node *) Pointer to the node you want to
  688.             insert.
  689.  
  690.  
  691. RemHead()
  692.  
  693.   This function will remove a note at the head of a list and
  694.   returns a pointer to the removed node.
  695.  
  696.   Synopsis: node = RemHead( list )
  697.  
  698.   list:     (struct List *) Pointer to the list you wish to
  699.             remove the head node from.
  700.  
  701.   node:     (struct Node *) Pointer to the node you have
  702.             removed, or NULL if there were no more nodes to
  703.             remove.
  704.  
  705.  
  706. RemTail()
  707.  
  708.   This function will remove a note at the tail of a list and
  709.   returns a pointer to the removed node.
  710.  
  711.   Synopsis: node = RemTail( list )
  712.  
  713.   list:     (struct List *) Pointer to the list you wish to
  714.             remove the tail node from.
  715.  
  716.   node:     (struct Node *) Pointer to the node you have
  717.             removed, or NULL if there were no more nodes to
  718.             remove.
  719.  
  720.  
  721. Enqueue()
  722.  
  723.   This function will insert nodes into lists considering the
  724.   node's priority. The higher priority the closer to the head
  725.   they are placed and vice versa.
  726.   
  727.   NOTE! This function can of course not be used to handle mini
  728.   lists. (Mini nodes do not have any priority field.)
  729.  
  730.   Synopsis: Enqueue( list, node );
  731.  
  732.   list:     (struct List *) Pointer to the list you wish to
  733.             insert the node in.
  734.  
  735.   node:     (struct Node *) Pointer to the node you want to
  736.             insert.
  737.  
  738.  
  739. FindName()
  740.  
  741.   This function will scan a list and search for nodes by their
  742.   name. It will return a pointer to the first node with the
  743.   specified name or NULL if no more node could be found. If it
  744.   found a node you simply have to call it again to find the
  745.   next.
  746.  
  747.   NOTE! This function can of course not be used to handle mini
  748.   lists. (Mini nodes do not have any name field.)
  749.  
  750.   Synopsis: node = FindName( list, name );
  751.  
  752.   node:     (struct Node *) If FindName() finds a node with the
  753.             name "name" it returns a pointer to it. If no node
  754.             was found it returns NULL.
  755.  
  756.   list:     (struct List *) Pointer to the list you want to
  757.             examine. If you have already found a node and want
  758.             to search for the next you should give it a pointer
  759.             to the last node you found.
  760.  
  761.   name:     (char *) Pointer to a NULL terminated string that
  762.             contains the name of the node(s) you look for.
  763.  
  764.  
  765.  
  766. 3.8  EXAMPLES
  767.  
  768. Example 1
  769.   Demonstrates how to create a list with three nodes. (Not very
  770.   amazing, but useful to know.)
  771.  
  772. Example 2
  773.   Demonstrates how to scan through a list from the head to the
  774.   tail, and the other way around.
  775.  
  776. Example 3
  777.   Demonstrates how to scan through a list looking for nodes with
  778.   a special name. Uses the function FindName().
  779.  
  780.